{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "mbp_aki.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "authorship_tag": "ABX9TyPxpowtOrcHN95rfZ0PcROf",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/vitaldb/examples/blob/master/mbp_aki.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "bpQy0pzwVUBL"
      },
      "source": [
        "# 술 중 혈압에 따른 AKI 발생 위험\n",
        "본 예제에서는 오픈 데이터셋인 vitaldb 를 이용하여 술 중 혈압에 따른 급성 신손상 (acute kidney injury, AKI) 발생 위험을 구해보겠습니다."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "SqQZp4YdV2tg"
      },
      "source": [
        "## 필요 라이브러리 및 데이터 다운로드"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "9wmjfMpGN6_z",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 898
        },
        "outputId": "4c342d15-dc5f-4f26-9093-e50841896f56"
      },
      "source": [
        "import pandas as pd\n",
        "import numpy as np\n",
        "\n",
        "df_cases = pd.read_csv(\"https://api.vitaldb.net/cases\")  # 임상 정보\n",
        "df_trks = pd.read_csv('https://api.vitaldb.net/trks')  # 트랙 목록\n",
        "df_labs = pd.read_csv('https://api.vitaldb.net/labs')  # 검사 결과\n",
        "df_cases"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>caseid</th>\n",
              "      <th>death_inhosp</th>\n",
              "      <th>casestart</th>\n",
              "      <th>caseend</th>\n",
              "      <th>anestart</th>\n",
              "      <th>aneend</th>\n",
              "      <th>opstart</th>\n",
              "      <th>opend</th>\n",
              "      <th>adm</th>\n",
              "      <th>dis</th>\n",
              "      <th>devices</th>\n",
              "      <th>tracks</th>\n",
              "      <th>casedur</th>\n",
              "      <th>filesize</th>\n",
              "      <th>age</th>\n",
              "      <th>sex</th>\n",
              "      <th>height</th>\n",
              "      <th>weight</th>\n",
              "      <th>bmi</th>\n",
              "      <th>asa</th>\n",
              "      <th>emop</th>\n",
              "      <th>department</th>\n",
              "      <th>optype</th>\n",
              "      <th>dx</th>\n",
              "      <th>opname</th>\n",
              "      <th>approach</th>\n",
              "      <th>position</th>\n",
              "      <th>ane_type</th>\n",
              "      <th>opdur</th>\n",
              "      <th>anedur</th>\n",
              "      <th>los_postop</th>\n",
              "      <th>los_icu</th>\n",
              "      <th>preop_htn</th>\n",
              "      <th>preop_dm</th>\n",
              "      <th>preop_ecg</th>\n",
              "      <th>preop_pft</th>\n",
              "      <th>preop_hb</th>\n",
              "      <th>preop_plt</th>\n",
              "      <th>preop_pt</th>\n",
              "      <th>preop_aptt</th>\n",
              "      <th>preop_na</th>\n",
              "      <th>preop_k</th>\n",
              "      <th>preop_glucose</th>\n",
              "      <th>preop_alb</th>\n",
              "      <th>preop_got</th>\n",
              "      <th>preop_gpt</th>\n",
              "      <th>preop_bun</th>\n",
              "      <th>preop_cr</th>\n",
              "      <th>preop_ph</th>\n",
              "      <th>preop_hco3</th>\n",
              "      <th>preop_be</th>\n",
              "      <th>preop_pao2</th>\n",
              "      <th>preop_paco2</th>\n",
              "      <th>preop_spo2</th>\n",
              "      <th>cormack</th>\n",
              "      <th>airway</th>\n",
              "      <th>tubesize</th>\n",
              "      <th>dltubesize</th>\n",
              "      <th>lmasize</th>\n",
              "      <th>iv1</th>\n",
              "      <th>iv2</th>\n",
              "      <th>aline1</th>\n",
              "      <th>aline2</th>\n",
              "      <th>cline1</th>\n",
              "      <th>cline2</th>\n",
              "      <th>intraop_ebl</th>\n",
              "      <th>intraop_uo</th>\n",
              "      <th>intraop_rbc</th>\n",
              "      <th>intraop_ffp</th>\n",
              "      <th>intraop_crystalloid</th>\n",
              "      <th>intraop_colloid</th>\n",
              "      <th>intraop_ppf</th>\n",
              "      <th>intraop_mdz</th>\n",
              "      <th>intraop_ftn</th>\n",
              "      <th>intraop_rocu</th>\n",
              "      <th>intraop_vecu</th>\n",
              "      <th>intraop_eph</th>\n",
              "      <th>intraop_phe</th>\n",
              "      <th>intraop_epi</th>\n",
              "      <th>intraop_ca</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>11520</td>\n",
              "      <td>-540</td>\n",
              "      <td>10860</td>\n",
              "      <td>-540</td>\n",
              "      <td>10380</td>\n",
              "      <td>-236220</td>\n",
              "      <td>627780</td>\n",
              "      <td>4</td>\n",
              "      <td>78</td>\n",
              "      <td>192</td>\n",
              "      <td>21.3</td>\n",
              "      <td>77.0</td>\n",
              "      <td>M</td>\n",
              "      <td>160.2</td>\n",
              "      <td>67.50</td>\n",
              "      <td>26.3</td>\n",
              "      <td>2.0</td>\n",
              "      <td>0</td>\n",
              "      <td>General surgery</td>\n",
              "      <td>Colorectal</td>\n",
              "      <td>Rectal cancer</td>\n",
              "      <td>Low anterior resection</td>\n",
              "      <td>Open</td>\n",
              "      <td>Lithotomy</td>\n",
              "      <td>General</td>\n",
              "      <td>145</td>\n",
              "      <td>180</td>\n",
              "      <td>8</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>Normal Sinus Rhythm</td>\n",
              "      <td>Normal</td>\n",
              "      <td>14.1</td>\n",
              "      <td>189.0</td>\n",
              "      <td>94.0</td>\n",
              "      <td>33.2</td>\n",
              "      <td>141.0</td>\n",
              "      <td>3.1</td>\n",
              "      <td>134.0</td>\n",
              "      <td>4.3</td>\n",
              "      <td>18.0</td>\n",
              "      <td>16.0</td>\n",
              "      <td>10.0</td>\n",
              "      <td>0.82</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>I</td>\n",
              "      <td>Oral</td>\n",
              "      <td>7.5</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>Right forearm</td>\n",
              "      <td>N</td>\n",
              "      <td>Left radial</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>NaN</td>\n",
              "      <td>300.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>350.0</td>\n",
              "      <td>0</td>\n",
              "      <td>120</td>\n",
              "      <td>0.0</td>\n",
              "      <td>100</td>\n",
              "      <td>70</td>\n",
              "      <td>0</td>\n",
              "      <td>10</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>15720</td>\n",
              "      <td>-1020</td>\n",
              "      <td>14940</td>\n",
              "      <td>1740</td>\n",
              "      <td>14640</td>\n",
              "      <td>-221160</td>\n",
              "      <td>1506840</td>\n",
              "      <td>5</td>\n",
              "      <td>75</td>\n",
              "      <td>262</td>\n",
              "      <td>26.3</td>\n",
              "      <td>54.0</td>\n",
              "      <td>M</td>\n",
              "      <td>167.3</td>\n",
              "      <td>54.80</td>\n",
              "      <td>19.6</td>\n",
              "      <td>2.0</td>\n",
              "      <td>0</td>\n",
              "      <td>General surgery</td>\n",
              "      <td>Stomach</td>\n",
              "      <td>Advanced gastric cancer</td>\n",
              "      <td>Subtotal gastrectomy</td>\n",
              "      <td>Open</td>\n",
              "      <td>Supine</td>\n",
              "      <td>General</td>\n",
              "      <td>215</td>\n",
              "      <td>245</td>\n",
              "      <td>19</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>Normal Sinus Rhythm</td>\n",
              "      <td>Normal</td>\n",
              "      <td>10.2</td>\n",
              "      <td>251.0</td>\n",
              "      <td>110.0</td>\n",
              "      <td>31.9</td>\n",
              "      <td>143.0</td>\n",
              "      <td>4.7</td>\n",
              "      <td>88.0</td>\n",
              "      <td>3.8</td>\n",
              "      <td>18.0</td>\n",
              "      <td>15.0</td>\n",
              "      <td>14.0</td>\n",
              "      <td>0.86</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>I</td>\n",
              "      <td>Oral</td>\n",
              "      <td>7.5</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>Left forearm</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>50.0</td>\n",
              "      <td>700.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>800.0</td>\n",
              "      <td>0</td>\n",
              "      <td>150</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0</td>\n",
              "      <td>100</td>\n",
              "      <td>0</td>\n",
              "      <td>20</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>3</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>4440</td>\n",
              "      <td>-540</td>\n",
              "      <td>4260</td>\n",
              "      <td>-540</td>\n",
              "      <td>3960</td>\n",
              "      <td>-218640</td>\n",
              "      <td>40560</td>\n",
              "      <td>5</td>\n",
              "      <td>80</td>\n",
              "      <td>73</td>\n",
              "      <td>6.6</td>\n",
              "      <td>62.0</td>\n",
              "      <td>M</td>\n",
              "      <td>169.1</td>\n",
              "      <td>69.70</td>\n",
              "      <td>24.4</td>\n",
              "      <td>1.0</td>\n",
              "      <td>0</td>\n",
              "      <td>General surgery</td>\n",
              "      <td>Biliary/Pancreas</td>\n",
              "      <td>Gallbladder stone</td>\n",
              "      <td>Cholecystectomy</td>\n",
              "      <td>Videoscopic</td>\n",
              "      <td>Reverse Trendelenburg</td>\n",
              "      <td>General</td>\n",
              "      <td>32</td>\n",
              "      <td>65</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>Normal Sinus Rhythm</td>\n",
              "      <td>Normal</td>\n",
              "      <td>14.2</td>\n",
              "      <td>373.0</td>\n",
              "      <td>103.0</td>\n",
              "      <td>30.3</td>\n",
              "      <td>144.0</td>\n",
              "      <td>4.9</td>\n",
              "      <td>87.0</td>\n",
              "      <td>4.2</td>\n",
              "      <td>17.0</td>\n",
              "      <td>34.0</td>\n",
              "      <td>14.0</td>\n",
              "      <td>1.18</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>I</td>\n",
              "      <td>Oral</td>\n",
              "      <td>7.5</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>Left forearm</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>200.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0</td>\n",
              "      <td>50</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>4</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>21000</td>\n",
              "      <td>-720</td>\n",
              "      <td>20280</td>\n",
              "      <td>2580</td>\n",
              "      <td>18180</td>\n",
              "      <td>-201120</td>\n",
              "      <td>576480</td>\n",
              "      <td>5</td>\n",
              "      <td>74</td>\n",
              "      <td>350</td>\n",
              "      <td>28.3</td>\n",
              "      <td>74.0</td>\n",
              "      <td>M</td>\n",
              "      <td>160.6</td>\n",
              "      <td>53.00</td>\n",
              "      <td>20.5</td>\n",
              "      <td>2.0</td>\n",
              "      <td>0</td>\n",
              "      <td>General surgery</td>\n",
              "      <td>Stomach</td>\n",
              "      <td>Advanced gastric cancer</td>\n",
              "      <td>Distal gastrectomy</td>\n",
              "      <td>Videoscopic</td>\n",
              "      <td>Reverse Trendelenburg</td>\n",
              "      <td>General</td>\n",
              "      <td>255</td>\n",
              "      <td>335</td>\n",
              "      <td>7</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>Normal Sinus Rhythm</td>\n",
              "      <td>Normal</td>\n",
              "      <td>14.4</td>\n",
              "      <td>275.0</td>\n",
              "      <td>103.0</td>\n",
              "      <td>34.5</td>\n",
              "      <td>141.0</td>\n",
              "      <td>4.2</td>\n",
              "      <td>108.0</td>\n",
              "      <td>4.1</td>\n",
              "      <td>23.0</td>\n",
              "      <td>18.0</td>\n",
              "      <td>10.0</td>\n",
              "      <td>0.96</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>I</td>\n",
              "      <td>Oral</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>Left forearm</td>\n",
              "      <td>N</td>\n",
              "      <td>Right radial</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>NaN</td>\n",
              "      <td>270.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>2700.0</td>\n",
              "      <td>0</td>\n",
              "      <td>80</td>\n",
              "      <td>0.0</td>\n",
              "      <td>100</td>\n",
              "      <td>100</td>\n",
              "      <td>0</td>\n",
              "      <td>50</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>5</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>21540</td>\n",
              "      <td>-960</td>\n",
              "      <td>22440</td>\n",
              "      <td>2640</td>\n",
              "      <td>21840</td>\n",
              "      <td>-67560</td>\n",
              "      <td>3734040</td>\n",
              "      <td>6</td>\n",
              "      <td>99</td>\n",
              "      <td>359</td>\n",
              "      <td>41.0</td>\n",
              "      <td>66.0</td>\n",
              "      <td>M</td>\n",
              "      <td>171.0</td>\n",
              "      <td>59.70</td>\n",
              "      <td>20.4</td>\n",
              "      <td>3.0</td>\n",
              "      <td>1</td>\n",
              "      <td>General surgery</td>\n",
              "      <td>Vascular</td>\n",
              "      <td>Aortic aneurysm</td>\n",
              "      <td>Aneurysmal repair</td>\n",
              "      <td>Open</td>\n",
              "      <td>Prone</td>\n",
              "      <td>General</td>\n",
              "      <td>295</td>\n",
              "      <td>350</td>\n",
              "      <td>45</td>\n",
              "      <td>13</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>Left anterior fascicular block</td>\n",
              "      <td>Normal</td>\n",
              "      <td>10.1</td>\n",
              "      <td>67.0</td>\n",
              "      <td>73.0</td>\n",
              "      <td>36.5</td>\n",
              "      <td>146.0</td>\n",
              "      <td>4.4</td>\n",
              "      <td>126.0</td>\n",
              "      <td>2.6</td>\n",
              "      <td>765.0</td>\n",
              "      <td>77.0</td>\n",
              "      <td>50.0</td>\n",
              "      <td>4.43</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>I</td>\n",
              "      <td>Oral</td>\n",
              "      <td>7.5</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>Right forearm</td>\n",
              "      <td>N</td>\n",
              "      <td>Right radial</td>\n",
              "      <td>N</td>\n",
              "      <td>Right IJV</td>\n",
              "      <td>N</td>\n",
              "      <td>2600.0</td>\n",
              "      <td>1490.0</td>\n",
              "      <td>8</td>\n",
              "      <td>8</td>\n",
              "      <td>7100.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0</td>\n",
              "      <td>160</td>\n",
              "      <td>0</td>\n",
              "      <td>10</td>\n",
              "      <td>900</td>\n",
              "      <td>0</td>\n",
              "      <td>2100</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6383</th>\n",
              "      <td>6384</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>15240</td>\n",
              "      <td>-240</td>\n",
              "      <td>15660</td>\n",
              "      <td>-240</td>\n",
              "      <td>15060</td>\n",
              "      <td>-215340</td>\n",
              "      <td>648660</td>\n",
              "      <td>5</td>\n",
              "      <td>73</td>\n",
              "      <td>254</td>\n",
              "      <td>9.3</td>\n",
              "      <td>64.0</td>\n",
              "      <td>M</td>\n",
              "      <td>161.5</td>\n",
              "      <td>63.00</td>\n",
              "      <td>24.2</td>\n",
              "      <td>1.0</td>\n",
              "      <td>0</td>\n",
              "      <td>General surgery</td>\n",
              "      <td>Stomach</td>\n",
              "      <td>Advanced gastric cancer</td>\n",
              "      <td>Total gastrectomy</td>\n",
              "      <td>Open</td>\n",
              "      <td>Supine</td>\n",
              "      <td>General</td>\n",
              "      <td>200</td>\n",
              "      <td>245</td>\n",
              "      <td>8</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>Normal Sinus Rhythm</td>\n",
              "      <td>Normal</td>\n",
              "      <td>14.5</td>\n",
              "      <td>279.0</td>\n",
              "      <td>109.0</td>\n",
              "      <td>31.0</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>100.0</td>\n",
              "      <td>4.2</td>\n",
              "      <td>31.0</td>\n",
              "      <td>33.0</td>\n",
              "      <td>13.0</td>\n",
              "      <td>0.99</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>I</td>\n",
              "      <td>Oral</td>\n",
              "      <td>7.5</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>Left forearm</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>100.0</td>\n",
              "      <td>330.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>550.0</td>\n",
              "      <td>0</td>\n",
              "      <td>150</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0</td>\n",
              "      <td>90</td>\n",
              "      <td>0</td>\n",
              "      <td>20</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6384</th>\n",
              "      <td>6385</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>20640</td>\n",
              "      <td>-540</td>\n",
              "      <td>21000</td>\n",
              "      <td>-540</td>\n",
              "      <td>19800</td>\n",
              "      <td>-225600</td>\n",
              "      <td>1675200</td>\n",
              "      <td>5</td>\n",
              "      <td>76</td>\n",
              "      <td>344</td>\n",
              "      <td>29.0</td>\n",
              "      <td>69.0</td>\n",
              "      <td>M</td>\n",
              "      <td>159.3</td>\n",
              "      <td>62.30</td>\n",
              "      <td>24.6</td>\n",
              "      <td>2.0</td>\n",
              "      <td>0</td>\n",
              "      <td>General surgery</td>\n",
              "      <td>Colorectal</td>\n",
              "      <td>Colon submucosal tumor, unknown behavior</td>\n",
              "      <td>Ultralow anterior resection</td>\n",
              "      <td>Videoscopic</td>\n",
              "      <td>Lithotomy</td>\n",
              "      <td>General</td>\n",
              "      <td>285</td>\n",
              "      <td>335</td>\n",
              "      <td>20</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>Normal Sinus Rhythm</td>\n",
              "      <td>Normal</td>\n",
              "      <td>15.2</td>\n",
              "      <td>239.0</td>\n",
              "      <td>114.0</td>\n",
              "      <td>28.7</td>\n",
              "      <td>144.0</td>\n",
              "      <td>4.0</td>\n",
              "      <td>140.0</td>\n",
              "      <td>3.7</td>\n",
              "      <td>18.0</td>\n",
              "      <td>28.0</td>\n",
              "      <td>19.0</td>\n",
              "      <td>0.84</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>7.5</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>Right forearm</td>\n",
              "      <td>Left forearm</td>\n",
              "      <td>Right radial</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>100.0</td>\n",
              "      <td>250.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>2500.0</td>\n",
              "      <td>0</td>\n",
              "      <td>100</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0</td>\n",
              "      <td>100</td>\n",
              "      <td>0</td>\n",
              "      <td>25</td>\n",
              "      <td>30</td>\n",
              "      <td>0</td>\n",
              "      <td>300</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6385</th>\n",
              "      <td>6386</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>19440</td>\n",
              "      <td>-660</td>\n",
              "      <td>19140</td>\n",
              "      <td>3540</td>\n",
              "      <td>18540</td>\n",
              "      <td>-200460</td>\n",
              "      <td>836340</td>\n",
              "      <td>5</td>\n",
              "      <td>76</td>\n",
              "      <td>324</td>\n",
              "      <td>31.4</td>\n",
              "      <td>61.0</td>\n",
              "      <td>F</td>\n",
              "      <td>151.7</td>\n",
              "      <td>43.25</td>\n",
              "      <td>18.8</td>\n",
              "      <td>1.0</td>\n",
              "      <td>0</td>\n",
              "      <td>General surgery</td>\n",
              "      <td>Stomach</td>\n",
              "      <td>Early gastric cancer</td>\n",
              "      <td>Distal gastrectomy</td>\n",
              "      <td>Videoscopic</td>\n",
              "      <td>Supine</td>\n",
              "      <td>General</td>\n",
              "      <td>245</td>\n",
              "      <td>310</td>\n",
              "      <td>10</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>Normal Sinus Rhythm</td>\n",
              "      <td>Normal</td>\n",
              "      <td>12.6</td>\n",
              "      <td>276.0</td>\n",
              "      <td>97.0</td>\n",
              "      <td>29.2</td>\n",
              "      <td>140.0</td>\n",
              "      <td>4.5</td>\n",
              "      <td>103.0</td>\n",
              "      <td>4.8</td>\n",
              "      <td>20.0</td>\n",
              "      <td>19.0</td>\n",
              "      <td>15.0</td>\n",
              "      <td>0.66</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>I</td>\n",
              "      <td>Oral</td>\n",
              "      <td>7.0</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>Left forearm</td>\n",
              "      <td>N</td>\n",
              "      <td>Right radial</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>100.0</td>\n",
              "      <td>450.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1300.0</td>\n",
              "      <td>0</td>\n",
              "      <td>70</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0</td>\n",
              "      <td>130</td>\n",
              "      <td>0</td>\n",
              "      <td>10</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6386</th>\n",
              "      <td>6387</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>12000</td>\n",
              "      <td>-540</td>\n",
              "      <td>12840</td>\n",
              "      <td>1740</td>\n",
              "      <td>12240</td>\n",
              "      <td>-227760</td>\n",
              "      <td>377040</td>\n",
              "      <td>5</td>\n",
              "      <td>78</td>\n",
              "      <td>200</td>\n",
              "      <td>17.3</td>\n",
              "      <td>24.0</td>\n",
              "      <td>F</td>\n",
              "      <td>155.7</td>\n",
              "      <td>55.50</td>\n",
              "      <td>22.9</td>\n",
              "      <td>1.0</td>\n",
              "      <td>0</td>\n",
              "      <td>General surgery</td>\n",
              "      <td>Biliary/Pancreas</td>\n",
              "      <td>Common bile duct stone without obstruction</td>\n",
              "      <td>Choledochal cyst excision</td>\n",
              "      <td>Robotic</td>\n",
              "      <td>Supine</td>\n",
              "      <td>General</td>\n",
              "      <td>155</td>\n",
              "      <td>185</td>\n",
              "      <td>6</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>Normal Sinus Rhythm</td>\n",
              "      <td>Normal</td>\n",
              "      <td>12.5</td>\n",
              "      <td>214.0</td>\n",
              "      <td>90.0</td>\n",
              "      <td>32.2</td>\n",
              "      <td>142.0</td>\n",
              "      <td>3.6</td>\n",
              "      <td>95.0</td>\n",
              "      <td>4.4</td>\n",
              "      <td>16.0</td>\n",
              "      <td>10.0</td>\n",
              "      <td>7.0</td>\n",
              "      <td>0.65</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>I</td>\n",
              "      <td>Oral</td>\n",
              "      <td>7.0</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>Right forearm</td>\n",
              "      <td>Left forearm</td>\n",
              "      <td>Left radial</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>N</td>\n",
              "      <td>NaN</td>\n",
              "      <td>60.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1150.0</td>\n",
              "      <td>0</td>\n",
              "      <td>120</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0</td>\n",
              "      <td>50</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6387</th>\n",
              "      <td>6388</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>10260</td>\n",
              "      <td>-60</td>\n",
              "      <td>10140</td>\n",
              "      <td>-60</td>\n",
              "      <td>9540</td>\n",
              "      <td>-312060</td>\n",
              "      <td>379140</td>\n",
              "      <td>5</td>\n",
              "      <td>80</td>\n",
              "      <td>171</td>\n",
              "      <td>14.8</td>\n",
              "      <td>47.0</td>\n",
              "      <td>F</td>\n",
              "      <td>150.0</td>\n",
              "      <td>51.50</td>\n",
              "      <td>22.9</td>\n",
              "      <td>2.0</td>\n",
              "      <td>0</td>\n",
              "      <td>Gynecology</td>\n",
              "      <td>Major resection</td>\n",
              "      <td>Epithelial ovarian cancer unknown stage</td>\n",
              "      <td>Debulking surgery</td>\n",
              "      <td>Open</td>\n",
              "      <td>Lithotomy</td>\n",
              "      <td>General</td>\n",
              "      <td>115</td>\n",
              "      <td>160</td>\n",
              "      <td>6</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>Normal Sinus Rhythm</td>\n",
              "      <td>Normal</td>\n",
              "      <td>8.6</td>\n",
              "      <td>549.0</td>\n",
              "      <td>64.0</td>\n",
              "      <td>34.6</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>124.0</td>\n",
              "      <td>3.4</td>\n",
              "      <td>17.0</td>\n",
              "      <td>7.0</td>\n",
              "      <td>8.0</td>\n",
              "      <td>0.64</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>I</td>\n",
              "      <td>Oral</td>\n",
              "      <td>7.0</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>Left forearm</td>\n",
              "      <td>Right hand</td>\n",
              "      <td>Left radial</td>\n",
              "      <td>N</td>\n",
              "      <td>Right IJV</td>\n",
              "      <td>N</td>\n",
              "      <td>NaN</td>\n",
              "      <td>800.0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1800.0</td>\n",
              "      <td>500</td>\n",
              "      <td>120</td>\n",
              "      <td>0.0</td>\n",
              "      <td>0</td>\n",
              "      <td>90</td>\n",
              "      <td>0</td>\n",
              "      <td>20</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>6388 rows × 80 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "      caseid  death_inhosp  casestart  ...  intraop_phe  intraop_epi  intraop_ca\n",
              "0          1             0          0  ...            0            0           0\n",
              "1          2             0          0  ...            0            0           0\n",
              "2          3             0          0  ...            0            0           0\n",
              "3          4             0          0  ...            0            0           0\n",
              "4          5             0          0  ...          900            0        2100\n",
              "...      ...           ...        ...  ...          ...          ...         ...\n",
              "6383    6384             0          0  ...            0            0           0\n",
              "6384    6385             0          0  ...           30            0         300\n",
              "6385    6386             0          0  ...            0            0           0\n",
              "6386    6387             0          0  ...            0            0           0\n",
              "6387    6388             0          0  ...            0            0           0\n",
              "\n",
              "[6388 rows x 80 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 4
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "lbUrsNBzV8ok"
      },
      "source": [
        "## 본 예제에서 사용할 case 선택\n",
        "응급 외과 수술 환자 중 100명만 사용해보자."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "WXeQT1UPWER5",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "dc3a52b3-3c6c-4832-a93f-b5e961ea041a"
      },
      "source": [
        "caseids = list(\n",
        "    set(df_trks[df_trks['tname'] == 'Solar8000/ART_MBP']['caseid']) & \n",
        "    set(df_cases[df_cases['department'] == 'General surgery']['caseid']) &\n",
        "    set(df_cases[df_cases['emop'] == 1]['caseid'])\n",
        ")\n",
        "caseids = caseids[:100]\n",
        "print('Total {} cases found'.format(len(caseids)))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Total 100 cases found\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "OkpKkCKbWL9B"
      },
      "source": [
        "## 각 케이스별 데이터 받아오기 및 계산\n",
        "vitaldb 로부터 각 case별 술 전 creatinine 농도 및 술 후 creatinine 농도를 구해보고 이로부터 AKI 발생 여부를 구해보자. 또한 수술 중 ART_MBP 데이터를 받아와 40-80 mmHg 의 각 threshold 들에 대해 전체 수술 중 해당 threshold  이하에 머무른 측정치의 비율을 구해보자."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "yckBVdfxWQEz",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "946fb23c-121a-4866-c6fc-18c9c6cc180b"
      },
      "source": [
        "# 혈압 기준치\n",
        "mbp_thresholds = np.arange(40, 80)\n",
        "\n",
        "# 최종 결과 저장\n",
        "df = pd.DataFrame()\n",
        "for caseid in caseids:\n",
        "    print('loading {}...'.format(caseid), flush=True, end='')\n",
        "\n",
        "    # 마취 종료 시각을 가져옴\n",
        "    aneend = df_cases[(df_cases['caseid'] == caseid)]['aneend'].values[0]\n",
        "\n",
        "    # 술 전 마지막 creatinine 농도\n",
        "    preop_cr = df_labs[(df_labs['caseid'] == caseid) & (df_labs['dt'] < 0) & (df_labs['name'] == 'Creatinine')].sort_values(by=['dt'], axis=0, ascending=False)['result'].values.flatten()\n",
        "    if len(preop_cr) == 0:\n",
        "        print('no preop cr')\n",
        "        continue\n",
        "    preop_cr = preop_cr[0]\n",
        "\n",
        "    # 술 후 48 시간 최대 creatinine 농도\n",
        "    postop_cr = df_labs[(df_labs['caseid'] == caseid) & (df_labs['dt'] > aneend) &\n",
        "        (df_labs['dt'] < aneend + 48 * 3600) & (df_labs['name'] == 'Creatinine')]['result'].max(skipna=True)\n",
        "    if not postop_cr or np.isnan(postop_cr):\n",
        "        print('no postop cr')\n",
        "        continue\n",
        "\n",
        "    # KDIGO stage I\n",
        "    aki = postop_cr > preop_cr * 1.5\n",
        "\n",
        "    # 술 중 혈압\n",
        "    tid_mbp = df_trks[(df_trks['caseid'] == caseid) & (df_trks['tname'] == 'Solar8000/ART_MBP')]['tid'].values[0]\n",
        "    mbps = pd.read_csv('https://api.vitaldb.net/' + tid_mbp).values[:,1]\n",
        "    mbps = mbps[~np.isnan(mbps)]\n",
        "    mbps = mbps[(mbps > 20) & (mbps < 150)]\n",
        "    if len(mbps) < 10:\n",
        "        print('no mbp')\n",
        "        continue\n",
        "\n",
        "    # 수술 중 혈압을 1단위로 증가시키면서 해당 시간 동안 머무른 비율을 구함\n",
        "    row = {'aki':aki}\n",
        "    for mbp_threshold in mbp_thresholds:\n",
        "        row['under{}'.format(mbp_threshold)] = np.nanmean(mbps < mbp_threshold) * 100\n",
        "\n",
        "    # 결과 행에 추가\n",
        "    df = df.append(row, ignore_index=True)\n",
        "\n",
        "    print('{} -> {}, {}'.format(preop_cr, postop_cr, 'AKI' if aki else 'no AKI'))\n",
        "\n",
        "print('{} AKI {:.1f}%'.format(df['aki'].sum(), df['aki'].mean() * 100))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "loading 6144...0.5 -> 0.57, no AKI\n",
            "loading 2063...0.71 -> 1.26, AKI\n",
            "loading 4112...no postop cr\n",
            "loading 4115...1.07 -> 0.9, no AKI\n",
            "loading 4116...0.63 -> 0.72, no AKI\n",
            "loading 24...no preop cr\n",
            "loading 29...0.78 -> 0.74, no AKI\n",
            "loading 32...no postop cr\n",
            "loading 4135...2.65 -> 2.3, no AKI\n",
            "loading 4144...17.74 -> 15.82, no AKI\n",
            "loading 6196...0.82 -> 1.0, no AKI\n",
            "loading 4150...no postop cr\n",
            "loading 4155...1.15 -> 2.19, AKI\n",
            "loading 60...9.36 -> 7.95, no AKI\n",
            "loading 2117...0.84 -> 0.89, no AKI\n",
            "loading 4168...0.73 -> 0.62, no AKI\n",
            "loading 2130...14.8 -> 9.02, no AKI\n",
            "loading 83...8.13 -> 7.36, no AKI\n",
            "loading 87...2.72 -> 2.35, no AKI\n",
            "loading 2138...no postop cr\n",
            "loading 2147...0.44 -> 0.52, no AKI\n",
            "loading 4195...0.89 -> 0.96, no AKI\n",
            "loading 2157...0.78 -> 0.74, no AKI\n",
            "loading 4213...0.88 -> 0.66, no AKI\n",
            "loading 6262...no preop cr\n",
            "loading 124...0.63 -> 0.63, no AKI\n",
            "loading 2174...5.42 -> 4.63, no AKI\n",
            "loading 4225...no postop cr\n",
            "loading 6273...no preop cr\n",
            "loading 138...0.72 -> 0.65, no AKI\n",
            "loading 6283...0.86 -> 0.77, no AKI\n",
            "loading 143...no preop cr\n",
            "loading 146...0.62 -> 1.8, AKI\n",
            "loading 6290...1.54 -> 1.79, no AKI\n",
            "loading 6292...9.47 -> 7.41, no AKI\n",
            "loading 6293...0.94 -> 1.09, no AKI\n",
            "loading 4247...0.95 -> 1.05, no AKI\n",
            "loading 6297...0.79 -> 0.63, no AKI\n",
            "loading 4251...0.98 -> 0.82, no AKI\n",
            "loading 4254...0.83 -> 1.22, no AKI\n",
            "loading 2214...no preop cr\n",
            "loading 6315...no postop cr\n",
            "loading 2223...1.52 -> 1.15, no AKI\n",
            "loading 177...15.94 -> 14.2, no AKI\n",
            "loading 185...0.45 -> 0.4, no AKI\n",
            "loading 2239...no preop cr\n",
            "loading 6335...0.95 -> 0.98, no AKI\n",
            "loading 2241...0.57 -> 0.54, no AKI\n",
            "loading 4290...0.89 -> 0.79, no AKI\n",
            "loading 4302...0.66 -> 0.74, no AKI\n",
            "loading 2255...0.88 -> 0.72, no AKI\n",
            "loading 4308...no preop cr\n",
            "loading 2265...0.84 -> 0.66, no AKI\n",
            "loading 2272...1.2 -> 1.79, no AKI\n",
            "loading 6372...1.01 -> 0.76, no AKI\n",
            "loading 232...no postop cr\n",
            "loading 4328...1.33 -> 1.78, no AKI\n",
            "loading 239...0.79 -> 1.45, AKI\n",
            "loading 6383...6.7 -> 6.14, no AKI\n",
            "loading 242...no postop cr\n",
            "loading 243...no postop cr\n",
            "loading 250...0.79 -> 0.73, no AKI\n",
            "loading 264...no postop cr\n",
            "loading 268...0.86 -> 0.86, no AKI\n",
            "loading 2327...0.61 -> 1.0, AKI\n",
            "loading 2331...1.37 -> 0.99, no AKI\n",
            "loading 284...6.82 -> 5.98, no AKI\n",
            "loading 2337...8.78 -> 8.65, no AKI\n",
            "loading 2345...1.28 -> 1.15, no AKI\n",
            "loading 4408...0.58 -> 0.63, no AKI\n",
            "loading 2372...0.95 -> 1.03, no AKI\n",
            "loading 2373...0.51 -> 0.55, no AKI\n",
            "loading 4433...1.0 -> 1.07, no AKI\n",
            "loading 349...1.07 -> 1.61, AKI\n",
            "loading 4449...0.21 -> 0.3, no AKI\n",
            "loading 355...2.24 -> 1.45, no AKI\n",
            "loading 4465...9.27 -> 7.3, no AKI\n",
            "loading 370...no preop cr\n",
            "loading 381...no preop cr\n",
            "loading 2432...no preop cr\n",
            "loading 387...2.05 -> 1.49, no AKI\n",
            "loading 4489...0.66 -> 0.76, no AKI\n",
            "loading 2447...1.02 -> 1.12, no AKI\n",
            "loading 4496...0.57 -> 0.53, no AKI\n",
            "loading 406...8.96 -> 8.5, no AKI\n",
            "loading 4509...10.76 -> 6.83, no AKI\n",
            "loading 415...0.51 -> 0.45, no AKI\n",
            "loading 427...0.91 -> 0.8, no AKI\n",
            "loading 431...15.12 -> 13.18, no AKI\n",
            "loading 2480...0.46 -> 0.55, no AKI\n",
            "loading 441...no preop cr\n",
            "loading 4538...0.53 -> 0.54, no AKI\n",
            "loading 2494...0.73 -> 0.63, no AKI\n",
            "loading 2501...1.03 -> 1.05, no AKI\n",
            "loading 2504...0.72 -> 0.61, no AKI\n",
            "loading 4556...0.9 -> 0.9, no AKI\n",
            "loading 464...no postop cr\n",
            "loading 2516...1.23 -> 1.86, AKI\n",
            "loading 476...no preop cr\n",
            "loading 477...0.58 -> 0.43, no AKI\n",
            "7.0 AKI 9.1%\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "YYHU8na4WV-0"
      },
      "source": [
        "## 각 혈압 기준치별로 AKI 예측에 대한 odd ratio를 구함\n",
        "case 별 AKI 발생 여부 및 각 threshold 에 머무른 비율을 이용하여 각 혈압 기준치가 AKI 발생 risk 를 얼마나 증가시키는지 odd ratio 를 구해보자."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "X5O0yxHJWcjh",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "47ca11cc-1630-4930-cbc0-daeaa1f388ad"
      },
      "source": [
        "import statsmodels.api as sm\n",
        "\n",
        "# univariate logistic regression을 돌려 odd ratio 를 구함\n",
        "df['intercept'] = 1\n",
        "df['aki'] = df['aki'].astype(bool)\n",
        "odd_ratios = []\n",
        "for mbp_threshold in mbp_thresholds:\n",
        "    c = 'under{}'.format(mbp_threshold)\n",
        "    model = sm.Logit(df['aki'], df[['intercept', c]])\n",
        "    res = model.fit()\n",
        "    b = res.params[c]\n",
        "    pval = res.pvalues[c]\n",
        "    odd_ratios.append(np.exp(b))\n",
        "    print('{}\\tb={:.3f}, exp(b)={:.3f}, pval={:.3f}'.format(c, b, np.exp(b), pval))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/usr/local/lib/python3.7/dist-packages/statsmodels/tools/_testing.py:19: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.\n",
            "  import pandas.util.testing as tm\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "Optimization terminated successfully.\n",
            "         Current function value: 0.281467\n",
            "         Iterations 7\n",
            "under40\tb=0.305, exp(b)=1.357, pval=0.042\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.277493\n",
            "         Iterations 7\n",
            "under41\tb=0.297, exp(b)=1.346, pval=0.030\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.275000\n",
            "         Iterations 7\n",
            "under42\tb=0.278, exp(b)=1.321, pval=0.027\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.274872\n",
            "         Iterations 7\n",
            "under43\tb=0.253, exp(b)=1.288, pval=0.030\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.272730\n",
            "         Iterations 7\n",
            "under44\tb=0.238, exp(b)=1.269, pval=0.027\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.266457\n",
            "         Iterations 7\n",
            "under45\tb=0.228, exp(b)=1.257, pval=0.017\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.261914\n",
            "         Iterations 7\n",
            "under46\tb=0.202, exp(b)=1.224, pval=0.012\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.258556\n",
            "         Iterations 7\n",
            "under47\tb=0.171, exp(b)=1.187, pval=0.012\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.253968\n",
            "         Iterations 7\n",
            "under48\tb=0.149, exp(b)=1.161, pval=0.010\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.247897\n",
            "         Iterations 7\n",
            "under49\tb=0.135, exp(b)=1.144, pval=0.009\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.242732\n",
            "         Iterations 7\n",
            "under50\tb=0.121, exp(b)=1.128, pval=0.006\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.236502\n",
            "         Iterations 7\n",
            "under51\tb=0.108, exp(b)=1.114, pval=0.004\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.234724\n",
            "         Iterations 7\n",
            "under52\tb=0.097, exp(b)=1.102, pval=0.003\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.234185\n",
            "         Iterations 7\n",
            "under53\tb=0.088, exp(b)=1.092, pval=0.003\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.234479\n",
            "         Iterations 7\n",
            "under54\tb=0.081, exp(b)=1.085, pval=0.003\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.235779\n",
            "         Iterations 7\n",
            "under55\tb=0.074, exp(b)=1.077, pval=0.002\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.237194\n",
            "         Iterations 7\n",
            "under56\tb=0.068, exp(b)=1.070, pval=0.002\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.238618\n",
            "         Iterations 7\n",
            "under57\tb=0.062, exp(b)=1.064, pval=0.002\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.240121\n",
            "         Iterations 7\n",
            "under58\tb=0.058, exp(b)=1.060, pval=0.002\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.242077\n",
            "         Iterations 7\n",
            "under59\tb=0.054, exp(b)=1.055, pval=0.002\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.243626\n",
            "         Iterations 7\n",
            "under60\tb=0.051, exp(b)=1.052, pval=0.002\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.246037\n",
            "         Iterations 7\n",
            "under61\tb=0.048, exp(b)=1.050, pval=0.003\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.249689\n",
            "         Iterations 7\n",
            "under62\tb=0.046, exp(b)=1.047, pval=0.003\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.253474\n",
            "         Iterations 7\n",
            "under63\tb=0.043, exp(b)=1.044, pval=0.004\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.257551\n",
            "         Iterations 7\n",
            "under64\tb=0.040, exp(b)=1.041, pval=0.006\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.261717\n",
            "         Iterations 7\n",
            "under65\tb=0.037, exp(b)=1.038, pval=0.008\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.265686\n",
            "         Iterations 7\n",
            "under66\tb=0.035, exp(b)=1.036, pval=0.011\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.269523\n",
            "         Iterations 7\n",
            "under67\tb=0.033, exp(b)=1.034, pval=0.016\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.273287\n",
            "         Iterations 7\n",
            "under68\tb=0.031, exp(b)=1.031, pval=0.022\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.276997\n",
            "         Iterations 7\n",
            "under69\tb=0.029, exp(b)=1.029, pval=0.032\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.280379\n",
            "         Iterations 7\n",
            "under70\tb=0.027, exp(b)=1.027, pval=0.045\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.282981\n",
            "         Iterations 7\n",
            "under71\tb=0.025, exp(b)=1.026, pval=0.059\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.285752\n",
            "         Iterations 7\n",
            "under72\tb=0.023, exp(b)=1.024, pval=0.078\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.288354\n",
            "         Iterations 7\n",
            "under73\tb=0.022, exp(b)=1.022, pval=0.103\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.290709\n",
            "         Iterations 7\n",
            "under74\tb=0.020, exp(b)=1.020, pval=0.132\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.292576\n",
            "         Iterations 7\n",
            "under75\tb=0.018, exp(b)=1.019, pval=0.163\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.293497\n",
            "         Iterations 7\n",
            "under76\tb=0.018, exp(b)=1.018, pval=0.181\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.294224\n",
            "         Iterations 7\n",
            "under77\tb=0.017, exp(b)=1.017, pval=0.198\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.294223\n",
            "         Iterations 7\n",
            "under78\tb=0.017, exp(b)=1.017, pval=0.201\n",
            "Optimization terminated successfully.\n",
            "         Current function value: 0.293717\n",
            "         Iterations 7\n",
            "under79\tb=0.018, exp(b)=1.018, pval=0.193\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "baARXo6kWeO4"
      },
      "source": [
        "## 결과를 그림으로\n",
        "대략 MBP가 60-65mmHg 이하로 머무르는 시간이 늘어날 수록 AKI 의 odd ratio가 증가함을 알 수 있다."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "mut5q3MeWnKQ",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 265
        },
        "outputId": "a5a90fcb-7d16-4748-9050-98d012cd70e7"
      },
      "source": [
        "import matplotlib.pyplot as plt\n",
        "\n",
        "# 결과를 그림으로\n",
        "plt.plot(mbp_thresholds, odd_ratios)\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3deXxV9Z3/8dcn+0oWkhDIxg4iEpaIWK3CaBWtVrFaS8WxVoextXV0fvqbzlZ/M/2103bstDpTtYhIay22VlFsXatVlNWwI7IvWYAkEAIJIQlJvvPHvcGACYTkhnPvzfv5eORx7z3fm9x3DuF9zz2rOecQEZHwFeF1ABER6V0qehGRMKeiFxEJcyp6EZEwp6IXEQlzUV4H6EhGRoYbPHiw1zFERELGqlWrDjjnMjsaC8qiHzx4MMXFxV7HEBEJGWa2p7MxrboREQlzKnoRkTCnohcRCXMqehGRMKeiFxEJcyp6EZEwp6IXEQlzYVX0j72zjY/3HvY6hohIUAmboj90tIkFK0u45cllvL2pwus4IiJB44xFb2bzzKzSzDZ2Mn6Dma03s7VmVmxml7Yba/FPX2tmiwIZ/FRpiTG8cu8lDM9KYvazxTy1eCe6qIqISNeW6OcD008z/g5Q6JwbD3wDmNtu7Jhzbrz/60vdj9k1Wf3i+N3si7lmbDY/eO0T/mnhBo63tPb2y4qIBLUzFr1zbjFQfZ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rgQSAf+4Vxn87vUOTcRuAa418wuaz/ofPvcerXfbUfZngCGAePx/dH/1INcUcBE4Ann3ATgKKesbvBwvnWWLRjmGwD+dclfAl44dczjv7eOsnk+3/xvLjfgexMfBCQC07v780K26IFLgC+Z2W7geXwfaR4FUv0fdQBygfJgyGZmv3HO7XM+jcAzwGQPsrUtLeCcq8S3TnIyUGFmAwH8t5XBks05V+Gca3HOtQJP4c18KwPKnHMr/I//gK9cg2G+dZgtSOZbm2uA1c65Cv/jYJhvbU7KFiTz7Upgl3Ouyjl3HHgJX690q99Ctuidc//onMt1zg3G97HrXefcbcBfgJv9T7sDeCVIss1q94dt+NatbTzX2cws0cyS2+4DV/lzLMI3v8Cj+dZZtrb55jcDD+abc24/UGpmo/yTrgA2EQTzrbNswTDf2pnJyatGPJ9v7ZyULUjmWwkwxcwS/H3R9vfWvX5zzoX8FzAV+KP//lBgJbAd30ex2CDK9i6wAd8fzm+AJA/yDAXW+b8+Bv7ZP70/vr0ftgF/BtKDKNuz/vm2Hl9BDPTo33I8UOzP8TKQFgzz7TTZgmW+JQIHgZR204JlvnWULVjm278Bm/198SwQ291+0ykQRETCXMiuuhERka5R0YuIhDkVvYhImFPRi4iEORW9iEiYU9GLiIQ5Fb2ISJj7X9YclJs5bnaBAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {
            "tags": [],
            "needs_background": "light"
          }
        }
      ]
    }
  ]
}